package com.csun.cmny.provider.dao;

import com.csun.cmny.core.support.MapResultHandler;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-09-19 15:59
 * @Description: the class session mapper
 */
@Repository
public class SessionMapper extends SqlSessionDaoSupport {

    @Resource
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    public Map<String, Object> queryReviseVarByGroupId(Long groupId) {

        MapResultHandler handler = new MapResultHandler();

        this.getSqlSession().select(OmcReviseVarMapper.class.getName()
                + ".queryReviseVarByGroupId", groupId, handler);

        return handler.getResult();
    }


    public Map<String,Object> queryOldOutVarByGroupId(Long groupId) {

        MapResultHandler handler = new MapResultHandler();

        this.getSqlSession().select(OmcOldOutVarMapper.class.getName()
                + ".queryOldOutVarByGroupId", groupId, handler);

        return handler.getResult();
    }

    public Map<Integer, Long> queryNursingGroupNum(Map<String, Object> params) {

        MapResultHandler handler = new MapResultHandler();

        this.getSqlSession().select(GroupMapper.class.getName()
                + ".queryNursingGroupNum", params, handler);

        return handler.getResult();
    }
}
